package com.epam.training.concurrency.second.task1;

import java.util.concurrent.Callable;

public class CalculateSerias implements Callable<Double> {

	private final int limit;
	private double sum;
	private static final double STEP = 0.0001;

	public Double call() {
		sum = 0.0;

		for (double i = 0; i < limit; i += STEP) {
			sum += Math.sin(i) * Math.cos(i) - Math.sin(i) * Math.cos(i);
		}

		return sum;
	}

	CalculateSerias(int limit) {
		this.limit = limit;
	}

}
